#!/usr/bin/python
# coding=utf-8
from flask import json

import login
from public import verification, config
from public.http import POST

authkey = login.authkey()

url_add = config.domain + '/device/add'

#  正常添加设备
def add():
    values = {"userid": "150650", "authkey": authkey,"uid":"VSTC123456ABCDE","password":"888888","name":"这是测试的设备名"}
    datajson = json.loads(POST(url_add, values))
    ret = datajson["ret"]
    return ret


url_show = config.domain + '/device/show'

# 获取设备列表
def show():
    values = {"userid": "150650", "authkey": authkey}
    datajson = json.loads(POST(url_add, values))
    ret = datajson["ret"]
    return ret

url_show = config.domain + '/device/update'

# 修改设备名称
def update_name():
    values = {"userid": "150650", "authkey": authkey,"uid":"VSTC123456ABCDE","key":"name","value":"修改后的设备名"}
    datajson = json.loads(POST(url_add, values))
    ret = datajson["ret"]
    return ret

if __name__ == '__main__':
    verification(add(), "正常添加设备", 200)
    verification(show(), "获取设备列表", 200)
    verification(update_name(), "获取设备列表", 200)

